** estimate effects for each cognitive domain 

***Inputs: 
* $Data/normscore_IV60_ability.dta


***Outputs: 
* $Results/AppendixselectionNplays.png
* $Results/Appendixselectionability.png
* $Results/Appendixselectionage.png


use $Data/normscore_IV60_ability.dta, clear


	by zip date, sort: egen Nplays = count(anon_id)


	by anon_id, sort: egen ability_score  = min(residmem)
	
	
	
	
	** look at average characteristics at zip level 
	
	collapse (firstnm) maxzipwi weighted_dailypm  weighted_wind_speed weighted_precipitation  Nplays day_of cut_temp  (mean) ability_score age residmem quin*   , by(zip date)
	
	gen monthyear = mofd(date)

	gen highpm =  weighted_dailypm > 25 & weighted_dailypm<. 

	label variable highpm "Daily PM2.5 $>$ 25" 
	
	
	
	
	reghdfe Nplays highpm weighted_wind_speed weighted_precipitation,  absorb(cut_temp) cluster(zip monthyear)
	
	summ Nplays 
	
	
	eststo Nplays1 
	
	
	reghdfe ability_score highpm weighted_wind_speed weighted_precipitation,  absorb(cut_temp) cluster(zip monthyear)

	summ ability_score

	eststo ability1
	
	
	reghdfe age  highpm weighted_wind_speed weighted_precipitation,  absorb(cut_temp) cluster(zip monthyear)
	
	summ age
	
	eststo age1
	
	
	
	
	
	
	
	
	reghdfe Nplays maxzipwind weighted_wind_speed weighted_precipitation,  absorb(zip) cluster(zip monthyear)
	
	
	eststo Nplays1wind
	
	
	reghdfe ability_score maxzipwind weighted_wind_speed weighted_precipitation,  absorb(zip) cluster(zip monthyear)

	
	eststo ability1wind
	
	reghdfe age  maxzipwind weighted_wind_speed weighted_precipitation,  absorb(cut_temp zip monthyear) cluster(zip monthyear)
	
	
	eststo age1wind
	
	
		
		
		coefplot (Nplays1, label("PM2.5>25") keep(highpm) ciopts(recast(rcap) lcolor(red))  mcolor(red) msymbol(D) msize(small))   (Nplays1wind, label("Wind IV") keep(maxzipwind) ciopts(recast(rcap) lcolor(red))  mcolor(red) msymbol(o) msize(small))  ,  ///
		  vertical levels(95) yline(0)  legend(rows(1) ) xlabel(none) 
		
				graph export $Results/AppendixselectionNplays.png, replace

		
		
		coefplot (ability1,  label("PM2.5>25") keep(highpm) ciopts(recast(rcap) lcolor(orange)) msymbol(D) mcolor(orange))  (ability1wind,  label("Wind IV") keep(maxzipwind) ciopts(recast(rcap) lcolor(orange)) msymbol(o)  mcolor(orange)),  ///
		  vertical levels(95) yline(0)  legend(rows(1) ) xlabel(none) 
		
		
						graph export $Results/Appendixselectionability.png, replace

		
		coefplot  (age1,  label("PM2.5>25") keep(highpm) ciopts(recast(rcap) lcolor(gold)) mcolor(gold) msymbol(D) msize(small) )  (age1wind,  label("Wind IV") keep(maxzipwind) ciopts(recast(rcap) lcolor(gold)) mcolor(gold) msymbol(o) msize(small) ) ,  ///
		  vertical levels(95) yline(0)  legend(rows(1) ) xlabel(none) 
		
							
							graph export $Results/Appendixselectionage.png, replace

		
		
		
		
